import {
  request
} from './request'

export function getCateList() {
  return request({
    url: 'categories',
  })
}

export function getAttributes(id, sel) {
  return request({
    url: `categories/${id}/attributes`,
    params: {
      sel
    }
  })
}

export function addParams(id, attr_name, attr_sel) {
  return request({
    url: `categories/${id}/attributes`,
    method: 'post',
    data: {
      attr_name,
      attr_sel
    }
  })
}

export function getParamById(id, attrId, attr_sel) {
  return request({
    url: `categories/${id}/attributes/${attrId}`,
    params: {
      attr_sel
    }
  })
}

export function editParams(id, attrId, attr_name, attr_sel) {
  return request({
    url: `categories/${id}/attributes/${attrId}`,
    method: 'put',
    data: {
      attr_name,
      attr_sel
    }
  })
}

export function removeParam(id, attrId) {
  return request({
    url: `categories/${id}/attributes/${attrId}`,
    method: 'delete',
  })
}

export function submitTag(id, attrId, config) {
  console.log(config);
  return request({
    url: `categories/${id}/attributes/${attrId}`,
    method: 'put',
    data: config
  })
}